package top.mingtea.propertymannagement.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.mingtea.propertymannagement.pojo.House;
import top.mingtea.propertymannagement.service.HouseService;

import java.util.List;

@RestController
@RequestMapping("/House")
public class HouseController {
    @Autowired
    private final HouseService houseService;

    public HouseController(HouseService houseService) {
        this.houseService = houseService;
    }

    @GetMapping("/getlist")
    public List<House> getAll() {
        return houseService.getAll();
    }

    @PostMapping("/add")
    public void add(@RequestBody House house) {
        houseService.add(house);
    }

    @DeleteMapping("/remove/{id}")
    public void remove(@PathVariable("id") int house_id) {
        houseService.remove(house_id);
    }

    @PutMapping("/update")
    public void update(@RequestBody House house) {
        houseService.update(house);
    }
}
